home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
C
/
creastdi.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-10-30
|
3KB
|
111 lines
/***********************************************************************
*
* Exec Support Functions -- Standard IO Requests
*
***********************************************************************/
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/memory.h"
#include "exec/interrupts.h"
#include "exec/ports.h"
#include "exec/libraries.h"
#include "exec/io.h"
#include "exec/tasks.h"
#include "exec/execbase.h"
extern APTR AllocMem();
/****** exec_support/CreateStdIO **************************************
*
* NAME
* CreateStdIO() -- create a standard IO request
*
* SYNOPSIS
* ioStdReq = CreateStdIO(ioReplyPort);
*
* FUNCTION
* Allocates memory for and initializes a new IO request block.
*
* INPUTS
* ioReplyPort - a pointer to an already initialized
* message port to be used for this IO request's
* reply port.
*
* RESULT
* Returns a pointer to the new block. Pointer is of the type:
* struct IOStdReq
* 0 indicates inability to allocate enough memory for either
* the request block.
*
* EXAMPLE
* struct IOStdReq *myBlock;
* if( (myBlock = CreateStdIO(myPort)) == NULL)
* printf("Insufficient memory or not enough signals!");
*
* SEE ALSO
* DeleteStdIO
*
***********************************************************************/
struct IOStdReq *CreateStdIO(ioReplyPort)
struct MsgPort *ioReplyPort;
{
struct IOStdReq *ioStdReq;
if (ioReplyPort == 0)
return ((struct IOStdReq *) 0);
ioStdReq = AllocMem (sizeof (*ioStdReq), MEMF_CLEAR | MEMF_PUBLIC);
if (ioStdReq == 0)
return ((struct IOStdReq *) 0);
ioStdReq -> io_Message.mn_Node.ln_Type = NT_MESSAGE;
ioStdReq -> io_Message.mn_Node.ln_Pri = 0;
ioStdReq -> io_Message.mn_ReplyPort = ioReplyPort;
return (ioStdReq);
}
/****** exec_support/DeleteStdIO ***************************************
*
* NAME
* DeleteStdIO(ioStdReq) - return memory allocated for IO request
*
* SYNOPSIS
* DeleteStdIO(ioStdReq);
*
* FUNCTION
* See summary line at NAME. Also frees the signal bit which
* had been allocated by the call to CreateStdIO.
*
* INPUTS
* A pointer to the IOStdReq block whose resources are to be freed.
*
* RESULT
* Frees the memory. Returns (no error conditions shown)
*
* EXAMPLE
* struct IOStdReq *myBlock;
* DeleteStdIO(myBlock);
*
* SEE ALSO
* CreateStdIO
*
**************************************************************************/
DeleteStdIO(ioStdReq)
struct IOStdReq *ioStdReq;
{
ioStdReq -> io_Message.mn_Node.ln_Type = 0xff;
ioStdReq -> io_Device = (struct Device *) -1;
ioStdReq -> io_Unit = (struct Unit *) -1;
FreeMem (ioStdReq, sizeof (*ioStdReq));
}